package com.yejiarong.weather.common.config;

import com.yejiarong.weather.common.interceptor.RequestInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author YeJR
 */
@Slf4j
@Order(-1)
@Configuration
public class SpringMvcConfig implements WebMvcConfigurer {

    /**
     * 注册拦截器
     *
     * @param registry 注册管理
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        WebMvcConfigurer.super.addInterceptors(registry);
        registry.addInterceptor(new RequestInterceptor()).addPathPatterns("/**");
    }
}
